package de.sendorian.util.htmlparser;


import org.apache.commons.lang.StringUtils;
import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.filters.TagNameFilter;

public class LinkNameFilter implements NodeFilter {
	private static final long serialVersionUID = 1L;

	private String name;


	public LinkNameFilter(String name) {
		this.name = name;
	}


	public boolean accept(Node node) {
		if (new TagNameFilter("a").accept(node)) {
			if (node.getChildren() != null && node.getChildren().size() == 1) {
				String childText = StringUtils.trim(node.getFirstChild().getText());
				return StringUtils.equals(childText, name);
			}
		}
		return false;
	}

}
